namespace GadgetStore.Data.Migrations
{
    using GadgetStore.Data.Models;
    using Microsoft.AspNet.Identity;
    using Microsoft.AspNet.Identity.EntityFramework;
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;

    internal sealed class Configuration : DbMigrationsConfiguration<GadgetStore.Data.ApplicationDbContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = false;
        }

        protected override void Seed(GadgetStore.Data.ApplicationDbContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //
            var UserStore = new UserStore<ApplicationUser>(context);
            var UserManager = new UserManager<ApplicationUser>(UserStore);
            var RoleStore = new RoleStore<IdentityRole>(context);
            var RoleManager = new RoleManager<IdentityRole>(RoleStore);
            if (!RoleManager.RoleExists("Admin"))
            {
                IdentityRole Role = new IdentityRole("Admin");
                RoleManager.Create(Role);
            }
            if (!RoleManager.RoleExists("User"))
            {
                IdentityRole Role = new IdentityRole("User");
                RoleManager.Create(Role);
            }
            if (!context.Users.Any(u => u.UserName == "Admin@me.com"))
            {
                ApplicationUser User = new ApplicationUser();
                User.UserName = "Admin@me.com";
                UserManager.Create(User, "123456");
                UserManager.AddToRole(User.Id, "Admin");
            }
            if (!context.Users.Any(u => u.UserName == "User@me.com"))
            {
                ApplicationUser User = new ApplicationUser();
                User.UserName = "User@me.com";
                UserManager.Create(User, "123456");
                UserManager.AddToRole(User.Id, "User");
            }
            context.Gadgets.AddOrUpdate(
                new Gadget() { Name = "Lock Pick Earrings", Descript = "An elegant accessory perfect for quick escapes, late nights, and lost keys. These acid etched stainless steel earrings are lightweight and feature a selection of picks, rakes, and a tension bar. They're decked out with silver plated rings and ear hooks - a perfect companion for Maker Faire, impressing the folks down at the local hackerspace, and DefCon shenanigans.This set is made of a durable lightweight .02 stainless steel with silver plated steel hardware. They are slimmer than most lock picks, keeping weight down and guaranteeing this set can be worn everyday.", TopPict = "http://i.imgur.com/VKgCNPa.jpg", Price = 34.99m, Qty = 10 },
                new Gadget() { Name = "Lipstick Stun Gun", Descript = "Red Lipstick Stun Gun with flashlight is portable and discreet. It packs 3 million volts of charge and is powered by a built-in rechargeable battery. Measuring only 5 inches tall and 1 inch around, this unit can fit into most any purse, pocket, backpack or briefcase. ", TopPict = "http://i.imgur.com/sE8uh3A.gif", Price = 29.99m, Qty = 10 },
                new Gadget() { Name = "Undercover Women's Ultimate Compression Tank", Descript = "It features two identical easy-access holsters to carry and conceal two handguns at the same time or carry spare magazines, handcuffs, cell phone or even an iPod on the opposite side of your handgun. ", TopPict = "http://i.imgur.com/kD9g0a1.jpg", Price = 69.99m, Qty = 10},
                new Gadget() { Name = "Women's Trench Coat", TopPict = "http://i.imgur.com/P4M0xCU.gif", Descript = "What's the problem with having a handful of digital gadgets at your every beck and call? You then have to find a place to stash them, which is not always convenient. All the adorable party clutches which we must have for special events? They don't really accommodate today's gadget girl. No space for your camera, your phone, your eReader. You can either settle on a bigger, slightly-less-cute bag or do what we do: throw on the Women's Trench Coat from SeV. With 18 pockets, it gives you lots of options. Heck, you could bring more stuff with you. Lipstick for touch-ups. Chapstick because it's awesome. Mittens. Kittens. (No, wait. Not kittens. We got carried away.) Sunglasses. Umbrella. Plus, tuck your wallet or clutch in a pocket, and you're totally hands-free. We're done here. Check please. This black, Mist, and Red 100% polyester, water- and stain-resistant coat features 18 pockets, SeV's patented Personal Area Network (PAN) for wire management, and their Weight Management System combined with NoBulge which keeps it from looking like you're smuggling the entire contents of your purse inside your jacket. Classic double-breasted styling with epaulets, accent buttons, and a wide adjustable belt set off the look. All sizes can hold an iPad in the designated PadPocket. This coat is machine washable. Details about how you can potentially toss it in the dryer ship with the coat, but it's always safe to hang dry.) Also, the coat does not come with all the tchotchke shown in the x-ray view. That's just so you can see where things go. Note: Please reference the table below to choose your size. These are the measurements of the person wearing the coat, not the coat itself.", Price = 129.99m, Qty = 10 }
                );
        }
    }
}
